package de.playmee.dialogs;

import android.app.ProgressDialog;
import android.content.Context;

public class ProgressBarDialog {
	
	// private final String TAG = "ProgressBarDialog";

	private Context context;
	private ProgressDialog dialog;
	
	public ProgressBarDialog(Context context) {
		this.context = context;
		create();
	}
	
	/**
	 * creates and initializes the dialog
	 */
	private void create() {
		dialog = new ProgressDialog(context);
		dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
		dialog.setCancelable(false);
	}
	
	/**
	 * sets the max value of the progress bar
	 * 
	 * @param max
	 */
	public void setMax(int max) {
		dialog.setMax(max);
	}
	
	/**
	 * sets the message of the dialog
	 * 
	 * @param message
	 */
	public void setMessage(String message) {
		dialog.setMessage(message);
	}
	
	/**
	 * shows a progress dialog with an animated progress bar
	 */
	public void show() {
		dialog.show();
	}
	
	/**
	 * shows a progress dialog with an animated progress bar
	 * 
	 * @param max
	 * @param message
	 */
	public void show(int max, String message) {
		setMax(max);
		setMessage(message);
		dialog.show();
	}
	
	/**
	 * sets the progress value of the bar
	 * 
	 * @param progress
	 */
	public void update(int progress) {
		dialog.setProgress(progress);
	}
	
	/**
	 * dismisses the progress bar dialog
	 */
	public void dismiss() {
		dialog.dismiss();
	}
}
